AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')

function ENT:Use(activator,caller)
	if self.dt.Power >= self.Power && !self.dt.Sparking then
		self.dt.Sparking = true
		timer.Create(tostring(self) .. "makefood", self.FoodTime, 1, self.MakeFood, self)
	end
end

function ENT:MakeFood()
	local spos = self.SparkPos
	local ang = self:GetAngles()
	local drug = ents.Create("item_food")
	drug:SetPos(self:GetPos() + ang:Forward() * spos.x + ang:Right() * spos.y + ang:Up() * spos.z)
	drug:Spawn()
	
	self.dt.Sparking = false
end
 
function ENT:CreateTimers()
	timer.Create(tostring(self) .. "makefood", self.FoodTime, 1, self.MakeFood, self)
end
 
function ENT:OnRemove()
	timer.Destroy(tostring(self) .. "makefood") 
end